<?php
	include dirname(dirname(__FILE__)).'/admin-verify.php';
	include dirname(__FILE__).'/functions.php';
	$ret=getEmployApplyInfo();
?>
<html>
	<head>
		<title>招聘管理</title>
		<?php include dirname(dirname(dirname(__FILE__))).'/include/common-header.php'; ?>
		<script type="text/javascript">
		$(document).ready(function(){

			$("#status").change(function() {
				var status=$(this).val();
				
				$(".info").hide();
				$("."+status+"").show();
			});

			$(".apply").click(function() {

				var param1=$(this).next().next().val();
			
				$.post('ajax/employ-sucess.php',{param1: param1}, function(data) {
					if (data=="yes"){
						alert("添加成功");
						location.reload();
					}
					if (data=="no") {
						alert("添加失败");
						location.reload();
					}
					
				});
			});

			$(".cancle").click(function() {

				var param1=$(this).next().val();
				$.post('ajax/employ-reject.php',{param1: param1}, function(data) {
					if (data=="yes"){
						alert("操作成功");
						location.reload();
					}
					if (data=="no") {
						alert("操作失败");
						location.reload();
					}
					
				});


			});




		});
		</script>
	</head>
	<body>

			<div class="container">
 						<table class="table table-striped table-bordered table-hover table-condensed " id="default-table">
			  <tr>
			  	<th>用户</th>
			  	<th>可值班时间</th>
			  	<th>申请时间</th>
			  	<th>状态<select id="status">
			  			<option value="0">待审核</option>
			  			<option value="1">成功</option>
			  			<option value="2">失败</option>
			  			</select></th>
			  	<th>操作</th>
			  </tr>
			  <?php


			  	while($row=mysql_fetch_array($ret)){
			  		$arr=explode(",", $row["apply_time"]);
			  		string:$apply_time=" ";
			  		foreach ($arr as $key => $value) {
			  			if($value%7){
			  				$day=$value%7;
			  			}else{
			  				$day=7;
			  			}
			  			$period=ceil(($value/7));
			  			$apply_time=$apply_time."星期".$day."   ".timeMap($period)."<br>";
			  		}
			  		echo '<tr class="'.$row["status"].' info">
			  	<th>'.$row["username"].'</th>
			  	<th>'.$apply_time.'</th>
			  	<th>'.$row["create_time"].'</th>·
			  	<th>'.statusMap($row["status"]).'</th>
			  	<th>';
			  	if ($row["status"]==0) {
			  		echo '<div><button class="btn btn-primary apply" >通过</button>
			  		<button class="btn btn-primary cancle" >拒绝</button>
			  		<input  type="hidden" value="'.base64_encode($row["id"]).'"/>
			  	</div>';
			  	}
			  	echo '
			  	</th>
			  </tr>';

			  	}

			  		
			  ?>
			  
			</table>
 				</div>

	</body>
</html>